<template>
  <u-popup :show="show" round="10px" @close="cancel" :closeOnClickOverlay="true" bgColor="transparent" mode="center">
    <div class="gzgzh">
      <div class="bc">
        <image src="/static/images/common/gzgzh.png" mode="scaleToFill" />
      </div>
      <div class="content">
        <div class="title">
          <div class="t1">请及时关注</div>
          <div class="t1">餐饮信息网公众号</div>
        </div>
        <div class="desc">第一时间收到新工作</div>
        <image
          :show-menu-by-longpress="true"
          @click="previewImage"
          class="qrcode"
          src="/static/images/common/qrcode.png"
          mode="scaleToFill"
        />
        <div class="text">长按二维码，关注公众号</div>
        <div class="text2">提升餐饮经营思路，把控餐饮行业动间</div>
      </div>
    </div>
    <div class="bottom" @click="$emit('close')">
      <image class="close" src="/static/images/common/close.png" mode="scaleToFill" />
    </div>
  </u-popup>
</template>

<script>
export default {
  name: "jfjlPopup",
  props: {
    show: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      isLogin: false,
      phone: "",
      userStatus: null, //resume_status,job_status
    };
  },
  computed: {},
  methods: {
    previewImage() {
      uni.previewImage({
        // 需要预览的图片链接列表。若无需预览，可以注释urls
        urls: [e.target.src],
        // 为当前显示图片的链接/索引值
        current: e.target.src,
        // 图片指示器样式
        indicator: "default",
        // 是否可循环预览
        loop: false,
        // 长按图片显示操作菜单，如不填默认为保存相册
        // longPressActions:{
        // 	itemList:[this.l('发送给朋友'),this.l]
        // },
        success: res => {
          console.log("previewImage res", res);
        },
        fail: err => {
          console.log("previewImage err", err);
        },
      });
    },
    async submit() {
      this.$emit("submit");
    },
    cancel() {
      this.$emit("cancel");
    },
    clickItem(type, type2) {
      switch (type) {
        case 1:
          if (type2 == "gl") {
            this.$togo("/pages2/regulateJobs");
          } else {
            this.$togo("/pages2/postOffer", { phone: this.phone });
          }

          break;
        case 2:
          if (type2 == "gl") {
            this.$togo("/pages2/regulateResume");
          } else {
            this.$togo("/pages2/postRecruitmentInformation", { phone: this.phone });
          }

          break;
        case 3:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
        case 4:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
        case 5:
          this.$layer.message("功能正在开发中,敬请期待...");
          break;
      }
      this.$emit("cancel");
    },
    getPhoneNumber1(e) {
      uni.login({
        provider: "weixin",
        success: async res => {
          this.code = res.code;
          // console.log(res);
          let res2 = await this.$http.requestSync("/wechat/login", { code: e.detail.code, loginCode: res.code });
          console.log(res2.header);
          this.$layer.message(res2.data.user_info.phone);
          this.$setStoraged("phone", res2.data.user_info.phone);
          this.$setStoraged("user_id", res2.data.user_info.id);
          this.$setStoraged("authration_token", res2.data.token);
          this.$setStoraged("open_id", res2.data.user_info.wechart_open_id);
          this.$togo("/pages2/postOffer", { phone: res2.data.user_info.phone });
        },
      });
    },
    getPhoneNumber2(e) {
      uni.login({
        provider: "weixin",
        success: async res => {
          this.code = res.code;
          // console.log(res);
          let res2 = await this.$http.requestSync("/wechat/login", { code: e.detail.code, loginCode: res.code });
          console.log(res2.header);
          this.$layer.message(res2.data.user_info.phone);
          this.$setStoraged("phone", res2.data.user_info.phone);
          this.$setStoraged("user_id", res2.data.user_info.id);
          this.$setStoraged("authration_token", res2.data.token);
          this.$setStoraged("open_id", res2.data.user_info.wechart_open_id);
          this.$togo("/pages2/postRecruitmentInformation", { phone: res2.data.user_info.phone });
        },
      });
    },
    // 查询用户是否发布过求职和招聘
    async getUserStatus() {
      let res = await this.$http.requestSync("/user/status");
      if (res.code == 200) {
        this.userStatus = res.data;
        console.log("getUserStatusgetUserStatusgetUserStatus", res);
      }
    },
  },
  watch: {},
  created() {
    if (this.$getStoraged("phone").length) {
      this.isLogin = true;
      this.phone = JSON.parse(this.$getStoraged("phone"));
      this.getUserStatus();
    } else {
      this.isLogin = false;
    }
  },
  // 组件周期函数--监听组件挂载完毕
  mounted() {},
  // 组件周期函数--监听组件数据更新之前
  beforeUpdate() {},
  // 组件周期函数--监听组件数据更新之后
  updated() {},
  // 组件周期函数--监听组件激活(显示)
  activated() {},
  // 组件周期函数--监听组件停用(隐藏)
  deactivated() {},
  // 组件周期函数--监听组件销毁之前
  beforeDestroy() {},
};
</script>

<style scoped lang="scss">
.gzgzh {
  width: 265px;
  height: 329px;
  .bc {
    width: 265px;
    height: 329px;
    image {
      width: 265px;
      height: 329px;
      position: relative;
      z-index: 0;
    }
  }
  .content {
    width: 265px;
    height: 329px;
    position: absolute;
    z-index: 2;
    top: 25px;
    .title {
      font-size: 14px;
      font-weight: 500;
      color: #333333;
      line-height: 22px;
      .t1 {
        width: 100%;
        text-align: center;
        font-size: 20px;
        font-weight: 600;
        color: #ffffff;
        margin-bottom: 3px;
      }
    }
    .desc {
      width: 167px;
      height: 24px;
      background: #ffa65b;
      border-radius: 16px 16px 16px 16px;
      font-size: 12px;
      font-weight: 400;
      text-align: center;
      line-height: 24px;
      margin: 10px auto 15px;
      color: #ffffff;
    }
    .qrcode {
      display: block;
      width: 133px;
      height: 133px;
      margin: 0px auto 6px;
    }
    .text {
      font-size: 12px;
      font-family: PingFang SC-Heavy, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      width: 100%;
      text-align: center;
      line-height: 24px;
    }
    .text2 {
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      margin-top: 4px;
      color: #ffd7b6;
      text-align: center;
      width: 100%;
    }
    .title2 {
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      margin: 18px auto 20px;
    }
    .shareBtn {
      width: 100%;
      height: 43px;
      image {
        width: 100%;
        height: 100%;
      }
    }
    button {
      border: none;
      background: transparent;
      padding: 0px;
    }
  }
}
.bottom {
  position: absolute;
  z-index: 99999999999;
  display: flex;
  justify-content: space-around;
  width: 100%;
  bottom: -50px;
  .close {
    width: 23px;
    height: 23px;
    margin: 10px auto;
  }
}
</style>
